package com.superquan.selfstudybootmybatis.utils.filter;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author zwq
 * @description 网关路由过滤拦截
 * @date 2022/5/11
 */
public class PreFilter {
    private static final Pattern uriPattern = Pattern.compile("^/api-[a-zA-Z]+/api/([a-zA-Z]+)(/security)?/(\\d+)/.*");
    private static final Pattern urlPattern = Pattern.compile("^/third-party/api/([a-zA-Z]+)(/security)?/(\\d+)/.*");

    public static void main(String[] args) {
        String url="/third-party/api/order/300000/v1/updateOrderStatus";
        Matcher matcher=urlPattern.matcher(url);
        if(matcher.matches()){
            String serviceName = matcher.group(1);
            String security = matcher.group(2);
            String apiCode = matcher.group(3);
            System.out.println("serviceName:"+serviceName);
            System.out.println("security:"+security);
            System.out.println("apiCode:"+apiCode);
        }else{
            System.out.println("未定义的api");
        }

    }
}
